home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Include / node.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-03  |  992 b   |  45 lines

  1. #ifndef Py_NODE_H
  2. #define Py_NODE_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /* Parse tree node interface */
  8.  
  9. typedef struct _node {
  10.     short        n_type;
  11.     char        *n_str;
  12.     short        n_lineno;
  13.     short        n_nchildren;
  14.     struct _node    *n_child;
  15. } node;
  16.  
  17. extern DL_IMPORT(node *) PyNode_New Py_PROTO((int type));
  18. extern DL_IMPORT(node *) PyNode_AddChild Py_PROTO((node *n, int type, char *str, int lineno));
  19. extern DL_IMPORT(void) PyNode_Free Py_PROTO((node *n));
  20.  
  21. /* Node access functions */
  22. #define NCH(n)        ((n)->n_nchildren)
  23. #define CHILD(n, i)    (&(n)->n_child[i])
  24. #define TYPE(n)        ((n)->n_type)
  25. #define STR(n)        ((n)->n_str)
  26.  
  27. /* Assert that the type of a node is what we expect */
  28. #ifndef Py_DEBUG
  29. #define REQ(n, type) { /*pass*/ ; }
  30. #else
  31. #define REQ(n, type) \
  32.     { if (TYPE(n) != (type)) { \
  33.         fprintf(stderr, "FATAL: node type %d, required %d\n", \
  34.             TYPE(n), type); \
  35.         abort(); \
  36.     } }
  37. #endif
  38.  
  39. extern DL_IMPORT(void) PyNode_ListTree Py_PROTO((node *));
  40.  
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44. #endif /* !Py_NODE_H */
  45.